package com.sangeng.service.impl;

import com.sangeng.utils.SecurityUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("ps")
public class HasPermisssionImpl {

    /**
     * 判断权限
     * @param permission 权限
     * @return
     */
    public boolean hasPermission(String permission){
        // 如果是超级管理员，直接返回true
        if(SecurityUtils.isAdmin()){
            return true;
        }
        // 否则进行权限判断
        else {
            List<String> permissions = SecurityUtils.getLoginUser().getPermissions();
            return permissions.contains(permission);
        }
    }
}
